package ord2.crawler;

import java.net.URL;

/**
 * This interface specifies a crawler. A crawler is used to get documents, content
 * that will be used in index operation.
 *
 * @author José Ivan
 * @author Edviges
 * 
 */
public interface Crawler {
    
    /**
     * Adds a URL that will be used to retrieve some content.
     * @param url Content URL
     */
    void addURL(URL url);
    
    /**
     * Removes a URL that is being used to retrieve some content.
     * @param url URL to be remove
     */
    void removeURL(URL url);
    
    /**
     * Starts the downloading job of this crawler
     * @throws Throwable If any problem occurs
     * @return True is crawler started false otherwise.
     */
    boolean start() throws Throwable;
    
    /**
     * Stops downloading job
     * @throws If any problem occurs
     */
    void stop() throws Throwable;
    
    /**
     * Verifies if download job is being executed.
     * @return true if is runnig or false otherwise
     */
    boolean isRunning();

    /**
     * Adds a listener that is gonna receive notifications from this crawler.
     * @param listener Listerner that is gonna be attached
     */
    void addListener(CrawlerListener listener);
}
